<?php

use think\migration\Migrator;
use think\migration\db\Column;

class LyUserWechatSubscribeMessage extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('user_wechat_subscribe_config')
            ->addColumn('user_id', 'integer', ['limit' => 11, 'null' => true, 'comment' => '用户id',"after"=>"id"])
            ->addColumn('applet_id', 'integer', ['limit' => 11, 'null' => true, 'comment' => '小程序id',"after"=>"user_id"])
            ->addColumn('subscribe_config', 'json', ['null' => true,'comment'=>'订阅配置','after' => 'applet_id'])
            ->addColumn('created_at', 'timestamp', ['default' => null,'null' => true, 'comment' => '创建时间',"after" => "operator_id"])
            ->addColumn('updated_at', 'timestamp', ['default' => null,'null' => true, 'comment' => '修改时间',"after" => "created_at"])
            ->addColumn('deleted_at', 'timestamp', ['null' => true, 'default' => null,'comment' => '删除时间',"after" => "updated_at"])
            ->setComment('微信订阅消息配置表')
            ->create();
    }


    public function down()
    {
        $this->table('user_wechat_subscribe_config')
            ->drop();
    }
}
